<?php

namespace services;

require_once ROOT . DS . 'library/restful/restful.php';
require_once ROOT . DS . 'library/db/src/PDOWrapper.php';
require_once ROOT . DS . 'library/autoload.php';
require_once 'logic/logic.php';

use services\logic as logic;
use services\logic\core as core;

class service extends \restful {

    private $_logics;

    public function __construct() {

        $this->_logics = new logic\logic(array(
                    new core\extra_time_logic(),
                    new core\historical_data_lookup(),
                    new core\stock_check(),
                    new core\supplier_lead_time_logic(),
                ));
    }

    public function router() {
        
        $this->get_time();
       
        /*
          $func = strtolower(trim(str_replace("/", "", $_REQUEST['cmd'])));

          if ((int) method_exists($this, $func) > 0) {
          $this->$func();
          if (in_array($this->_request['format'], array('json', 'html', 'xml'))) {
          $this->_content_type = $this->_request['format'];
          }
          } else {
          $this->response('', 404); // "Page not found".
          }
         * 
         */
    }

    public function get_time() {
        $sku = isset($this->_request['sku']) ? $this->_request['sku'] : -1;
        $time = $this->_logics->get_time();
        $this->response(json_encode(array($sku, $time)));
    }

}
?>


